﻿#pragma once

#include "basic_class.h"
#include "sqlite3.h"

#define _GAME_DB ":memory:"

namespace steel {

/*
* Database
*/
class Database : public BasicClass {
public:
	~jDatabase(void);

	static jDatabase * getInstance();

	bool Execute(char * query);
private:
	static jDatabase * _instance; ///< database class instance

	sqlite3 * _db; ///< database connection

	jDatabase(void); ///< constructor
	static int resultCalback(void *NotUsed, int argc, char **argv, char **azColName); ///< database result callback
};

/*
* Query
*/
class jDBQuery {
public:
	jDBQuery();
	~jDBQuery();

	bool nextRow();
	int fieldsCount();

	// string
	//const char * fieldValue(int nField);
	//const char * fieldValue(const char * name);
	// int
	//int fieldValue(int nField);
	//int fieldValue(const char * name);
	// float
	//float fieldValue(int nField);
	//float fieldValue(const char * name);
private:
	sqlite3_stmt * _res; ///< query result
};

}
